package com.ruoyi.rescheduling.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.rescheduling.domain.Reschedulingparameter;
import com.ruoyi.rescheduling.service.IReschedulingparameterService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 重调度模型参数配置Controller
 * 
 * @author wangming
 * @date 2024-01-27
 */
@RestController
@RequestMapping("/reschedulingparameter")
public class ReschedulingparameterController extends BaseController
{
    @Autowired
    private IReschedulingparameterService reschedulingparameterService;

    /**
     * 查询重调度模型参数配置列表
     */
    @RequiresPermissions("rescheduling:reschedulingparameter:list")
    @GetMapping("/list")
    public TableDataInfo list(Reschedulingparameter reschedulingparameter)
    {
        startPage();
        List<Reschedulingparameter> list = reschedulingparameterService.selectReschedulingparameterList(reschedulingparameter);
        return getDataTable(list);
    }

    /**
     * 导出重调度模型参数配置列表
     */
    @RequiresPermissions("rescheduling:reschedulingparameter:export")
    @Log(title = "重调度模型参数配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Reschedulingparameter reschedulingparameter)
    {
        List<Reschedulingparameter> list = reschedulingparameterService.selectReschedulingparameterList(reschedulingparameter);
        ExcelUtil<Reschedulingparameter> util = new ExcelUtil<Reschedulingparameter>(Reschedulingparameter.class);
        util.exportExcel(response, list, "重调度模型参数配置数据");
    }

    /**
     * 获取重调度模型参数配置详细信息
     */
    @RequiresPermissions("rescheduling:reschedulingparameter:query")
    @GetMapping(value = "/{agentname}")
    public AjaxResult getInfo(@PathVariable("agentname") String agentname)
    {
        return success(reschedulingparameterService.selectReschedulingparameterByAgentname(agentname));
    }

    /**
     * 新增重调度模型参数配置
     */
    @RequiresPermissions("rescheduling:reschedulingparameter:add")
    @Log(title = "重调度模型参数配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Reschedulingparameter reschedulingparameter)
    {
        return toAjax(reschedulingparameterService.insertReschedulingparameter(reschedulingparameter));
    }

    /**
     * 修改重调度模型参数配置
     */
    @RequiresPermissions("rescheduling:reschedulingparameter:edit")
    @Log(title = "重调度模型参数配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Reschedulingparameter reschedulingparameter)
    {
        return toAjax(reschedulingparameterService.updateReschedulingparameter(reschedulingparameter));
    }

    /**
     * 删除重调度模型参数配置
     */
    @RequiresPermissions("rescheduling:reschedulingparameter:remove")
    @Log(title = "重调度模型参数配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{agentnames}")
    public AjaxResult remove(@PathVariable String[] agentnames)
    {
        return toAjax(reschedulingparameterService.deleteReschedulingparameterByAgentnames(agentnames));
    }
}
